package com.little.pattern.observer.java;

import java.util.Observable;
import java.util.Observer;

/**
 * Created by littleshu on 18/5/5.
 */
public class XiaoZhang implements Observer {
    private Observable subject;


    public void tell(Observable subject) {
        this.subject = subject;
        this.subject.addObserver(this);
    }

    public void sleep() {
        System.out.println("小张在睡觉");
    }

    public void learn() {
        System.out.println("小张开始装做学习");
    }

    @Override
    public void update(Observable o, Object arg) {
        learn();
    }
}
